#include <stdio.h>

int tmp[16][16];
int ans = 256;

void var(int* x) {
	(*x) = (*x == 0) ? 1 : 0;
	return;
}

void change(int all[16][16], int n, int m, int i, int j) {
	var(&all[i][j]);
	if (i >= 1) var(&all[i - 1][j]);
	if (j >= 1) var(&all[i][j - 1]);
	if (i <= n - 2) var(&all[i + 1][j]);
	if (j <= m - 2) var(&all[i][j + 1]);
}

void getall(int all[16][16], int n, int m) {
	int i = 0;
	int j = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			tmp[i][j] = all[i][j];
		}
	}
}

int try(int all[16][16], int n, int m) {
	getall(all, n, m);
	int cnt = 0;
	int i = 0;
	int j = 0;
	for (i = 0; i < n - 1; i++) {
		for (j = 0; j < m; j++) {
			if (tmp[i][j] == 1) {
				cnt++;
				change(tmp, n, m, i + 1, j);
			}
		}
	}
	for (j = 0; j < m; j++) {
		if (tmp[i][j] == 1)return -1;
	}
	return cnt;
}
void dfs(int all[16][16], int step, int cnt, int n, int m) {
	if (step == m) {
		int tmpans = try(all, n, m);
		if (tmpans == -1) return;
		else if (tmpans + cnt > ans)
			ans = tmpans + cnt;
	}
	change(tmp, n, m, 0, step);
	dfs(all, step + 1, cnt + 1, n, m);
	change(tmp, n, m, 0, step);
	dfs(all, step + 1, cnt, n, m);
}

int main() {
	int n = 0;
	int m = 0;
	int i = 0;
	int j = 0;
	int all[16][16];
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		getchar();
		for (j = 0; j < m; j++)
			scanf("%c", &all[i][j]);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			all[i][j] -= '0';
	}
	dfs(all, 0, 0, n, m);
	printf("%d\n", ans);

	return 0;
}